<!DOCTYPE html>
<!-- saved from url=(0053)https://inst.eecs.berkeley.edu/~cs61a/fa20/lab/lab01/ -->
<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="description" content="CS 61A: Structure and Interpretation of Computer Programs">
    <meta name="keywords" content="CS 61A, Computer Science, CS, 61A, Programming, John DeNero, Berkeley, EECS">
    <meta name="author" content="Hany Farid, John DeNero">
    
    <meta name="viewport" content="width=device-width">

    <script src="./Lab 1_ Variables &amp; Functions, Control _ CS 61A Fall 2020_files/jquery.min.js.下载"></script>
    <script src="./Lab 1_ Variables &amp; Functions, Control _ CS 61A Fall 2020_files/bootstrap.min.js.下载"></script>
    <script src="./Lab 1_ Variables &amp; Functions, Control _ CS 61A Fall 2020_files/hl.js.下载"></script>
    <script>
        // we aren't registering builtins since
        //      (1) they don't render differently in the current CSS from other names
        //      (2) it's a mess to list all of them. You can extract from the site but that takes effort
        // if (1) ceases to be true, (2) might be worth the effort. For now, we're leaving as is
        hljsRegister({
            'keyword': "define if cond and or let begin lambda mu quote delay cons-stream set! quasiquote unquote unquote-splicing define-macro"
        });
        hljs.initHighlightingOnLoad();
    </script>
    <script src="./Lab 1_ Variables &amp; Functions, Control _ CS 61A Fall 2020_files/dark-mode.js.下载"></script>
    <link rel="stylesheet" href="./Lab 1_ Variables &amp; Functions, Control _ CS 61A Fall 2020_files/bootstrap.min.css">
    <link rel="stylesheet" href="./Lab 1_ Variables &amp; Functions, Control _ CS 61A Fall 2020_files/css">
    <link rel="stylesheet" href="./Lab 1_ Variables &amp; Functions, Control _ CS 61A Fall 2020_files/style.css">
    <link rel="stylesheet" href="./Lab 1_ Variables &amp; Functions, Control _ CS 61A Fall 2020_files/mono-blue.css">
    <link rel="icon" href="https://inst.eecs.berkeley.edu/~cs61a/fa20/assets/images/favicon.ico">

    

    <title>
Lab 1: Variables &amp; Functions, Control | CS 61A Fall 2020
</title>
  </head>

  <body id="index" class="home vsc-initialized" style="zoom: 1;">
    <nav class="navbar navbar-default navbar-static-top">
      <div class="container noselect">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse-section">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="https://inst.eecs.berkeley.edu/~cs61a/fa20/">
            <img style="max-width:60px; margin-top: -20px;" class="logo" src="./Lab 1_ Variables &amp; Functions, Control _ CS 61A Fall 2020_files/logo.png">
          </a>
        <button type="button" class="btn btn-primary" style="float: left; margin-top: 8px;"><span style="filter: grayscale(100%);">✏️</span></button></div>

        <div class="collapse navbar-collapse" id="navbar-collapse-section">
          <ul class="nav navbar-nav navbar-right">
            <li><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/weekly.html">Weekly Schedule</a></li>
            <li><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/office-hours.html">Office Hours</a></li>
            <li class="nav-item dropdown">
              <a class="nav-link dropdown-toggle" href="https://inst.eecs.berkeley.edu/~cs61a/fa20/lab/lab01/#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                Staff
              </a>
              <ul class="dropdown-menu" aria-labelledby="navbarDropdown">
                <li><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/instructor.html">Instructors</a></li>
                <li><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/TAs.html">TAs</a></li>
                <li><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/tutors.html">Tutors</a></li>
                <!-- <li><a href="/~cs61a/fa20/academic-interns.html">Academic Interns</a></li> -->
              </ul>
            </li>
            <li><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/resources.html">Resources</a></li>
            <li><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/articles/about.html">Syllabus</a></li>
            <li><a href="https://piazza.com/berkeley/fall2020/cs61a" target="_blank">Piazza</a></li>
            <li><a href="https://denero.org/feedback.html" target="_blank">Feedback</a></li>
<!--             <li><a href="https://edge.edx.org/courses/course-v1:BerkeleyX+CSW61A+2020_SP">EdX</a></li> -->
            <!-- <li><a href="https://scheme.cs61a.org">Scheme</a></li> -->
            <!-- <li><a href="https://sql.cs61a.org">SQL</a></li> -->
            <li><a href="https://code.cs61a.org/">Code</a></li>
            <li><a href="http://tutor.cs61a.org/">Tutor</a></li>
          </ul>
        </div>
      </div>
    </nav>

    <main id="content" class="container">
      
<div class="row">
  <div class="col-md-9">
    <header>
      <h1>
        
Lab 1: Variables &amp; Functions, Control

        
        
        <ul class="inline-block list-inline">
          <li><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/lab/lab01/lab01.zip" class="label label-outline">lab01.zip</a></li>
        </ul>
        
        
      </h1>
    </header>
    

<p><i>Due by 11:59pm on Tuesday, September 1.</i></p>




<h2 id="starter-files">Starter Files</h2>

<p>Download <a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/lab/lab01/lab01.zip">lab01.zip</a>.
Inside the archive, you will find starter files for the questions in this lab,
  along with a copy of the <a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/lab/lab01/ok">Ok</a> autograder.</p>






    
<p>Additionally, please fill out <a href="https://forms.gle/BP3tcRgqPhHq4Ymf9">this survey</a> with any issues you might have faced in Lab 0 Python installation or if you used the Windows automated installer.</p>

<p><strong>For quickly generating ok commands, you can now use the <a href="https://links.cs61a.org/ok-help">ok command generator</a>.</strong></p>


<h1 id="quick-logistics-review">Quick Logistics Review</h1>



        <button id="toggle-1" class="btn btn-outline btn-lg alwaystoggle toggle" style="display: inline-block;">
        Using Python<noscript> (enable JavaScript)</noscript>
        </button>
        <div class="solution toggle-1">

<h2 id="using-python">Using Python</h2>


<p>When running a Python file, you can use options on the command line
to inspect your code further. Here are a few that will come in handy.
If you want to learn more about other Python command-line options, take a look
at the <a href="https://docs.python.org/3.4/using/cmdline.html">documentation</a>.</p>

<ul>
  <li><p>Using no command-line options will run the code in the file you
  provide and return you to the command line.</p>

<pre><code class="hljs">python3 foo.py</code></pre></li>
  <li><p><strong><code>-i</code></strong>: The <code>-i</code> option runs your Python script, then opens an interactive
  session. In an interactive session, you run Python code line by line and get
  immediate feedback instead of running an entire file all at once. To exit,
  type <code>exit()</code> into the interpreter prompt. You can also use the keyboard
  shortcut <code>Ctrl-D</code> on Linux/Mac machines or <code>Ctrl-Z  Enter</code> on Windows.</p>

  <p>If you edit the Python file while running it interactively, you will need to
  exit and restart the interpreter in order for those changes to take effect.</p>

<pre><code class="hljs">python3 -i foo.py</code></pre></li>
  <li><p><strong><code>-m doctest</code></strong>: Runs doctests in a particular file. Doctests are
  surrounded by triple quotes (<code>"""</code>) within functions.</p>

  <p>Each test in the file consists of <code>&gt;&gt;&gt;</code> followed by some Python code and
  the expected output (though the <code>&gt;&gt;&gt;</code> are not seen in the output of the
  doctest command).</p>

<pre><code class="hljs"> python3 -m doctest foo.py</code></pre>

  </li></ul></div>
  <br>
  
        <button id="toggle-2" class="btn btn-outline btn-lg alwaystoggle toggle" style="display: inline-block;">
        Using OK<noscript> (enable JavaScript)</noscript>
        </button>
        <div class="solution toggle-2">

  <h2 id="using-ok">Using OK</h2>


<p>In 61A, we use a program called Ok for autograding labs, homeworks, and
projects. You should have Ok in the starter files downloaded at the start of
this lab. For more information on using Ok commands, learn more
<a href="http://cs61a.org/articles/using-ok.html">here</a>.</p>

<p><strong>You can quickly generate most ok commands at <a href="https://links.cs61a.org/ok-help">links.cs61a.org/ok-help</a>!</strong></p>

<p>To use Ok to run doctests for a
specified function, run the following command:</p>

<pre><code class="hljs">python3 ok -q &lt;specified function&gt;</code></pre>

<p>By default, only tests that did not pass will show up. You can use the <code>-v</code>
option to show all tests, including tests you have passed:</p>

<pre><code class="hljs">python3 ok -v</code></pre>

<p>You can also use the debug printing feature in OK by writing</p>

<pre><code class="hljs python">print(<span class="hljs-string">"DEBUG:"</span>, x)</code></pre>

<p>Finally, when you have finished all the questions in
<a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/lab/lab01/lab01.py">lab01.py</a>, you must submit the assignment using the
<code>--submit</code> option:</p>

<pre><code class="hljs sql">python3 ok <span class="hljs-comment">--submit</span></code></pre>

<p>For more Ok commands, visit <a href="https://cal-cs-61a-staff.github.io/ok-help/">here</a>.
</p></div><p></p>


<h1 id="topics">Topics</h1>


<p>Consult this section if you need a refresher on the material for this lab. It's
okay to skip directly to <a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/lab/lab01/#required-questions">the questions</a> and refer back
here should you get stuck.</p>


        <button id="toggle-3" class="btn btn-outline btn-lg alwaystoggle toggle" style="display: inline-block;">
        Division<noscript> (enable JavaScript)</noscript>
        </button>
        <div class="solution toggle-3">

<h2 id="division">Division</h2>


<p>Let's compare the different division-related operators in Python 3:</p>

<div class="table-responsive">
    <table class="table table-bordered">
      <tbody><tr>
        <th>True Division: <code>/</code> <br> (decimal division) </th>
        <th>Floor Division: <code>//</code> <br> (integer division) </th>
        <th>Modulo: <code>%</code> <br> (remainder) </th>

  </tr>
  <tr>
    <td align="left">
<pre><code class="hljs python"><span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-number">1</span> / <span class="hljs-number">5</span>
<span class="hljs-number">0.2</span>

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-number">25</span> / <span class="hljs-number">4</span>
<span class="hljs-number">6.25</span>

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-number">4</span> / <span class="hljs-number">2</span>
<span class="hljs-number">2.0</span>

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-number">5</span> / <span class="hljs-number">0</span>
ZeroDivisionError
</code></pre>
    </td>
    <td align="left">
<pre><code class="hljs python"><span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-number">1</span> // <span class="hljs-number">5</span>
<span class="hljs-number">0</span>

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-number">25</span> // <span class="hljs-number">4</span>
<span class="hljs-number">6</span>

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-number">4</span> // <span class="hljs-number">2</span>
<span class="hljs-number">2</span>

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-number">5</span> // <span class="hljs-number">0</span>
ZeroDivisionError
</code></pre>
    </td>
    <td align="left">
<pre><code class="hljs python"><span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-number">1</span> % <span class="hljs-number">5</span>
<span class="hljs-number">1</span>

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-number">25</span> % <span class="hljs-number">4</span>
<span class="hljs-number">1</span>

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-number">4</span> % <span class="hljs-number">2</span>
<span class="hljs-number">0</span>

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-number">5</span> % <span class="hljs-number">0</span>
ZeroDivisionError
</code></pre>
    </td>
  </tr>
</tbody></table>
</div>

<p>Notice that Python outputs <code>ZeroDivisionError</code> for certain cases. We will go over this later in this lab under <a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/lab/lab01/#error-messages">Error Messages</a>.</p>

<p>One useful technique involving the <code>%</code> operator is to check
whether a number <code>x</code> is divisible by another number <code>y</code>:</p>

<pre><code class="hljs">x % y == 0</code></pre>

<p>For example, in order to check if <code>x</code> is an even number:</p>

<pre><code class="hljs">x % 2 == 0</code></pre>

</div>
<br>

        <button id="toggle-4" class="btn btn-outline btn-lg alwaystoggle toggle" style="display: inline-block;">
        Functions<noscript> (enable JavaScript)</noscript>
        </button>
        <div class="solution toggle-4">

<h2 id="functions">Functions</h2>


<p>If we want to execute a series of statements over and over, we can abstract them away
into a function to avoid repeating code.</p>

<p>For example, let's say we want to know the results of multiplying the numbers 1-3 by
3 and then adding 2 to it. Here's one way to do it:</p>

<pre><code class="hljs python"><span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-number">1</span> * <span class="hljs-number">3</span> + <span class="hljs-number">2</span>
<span class="hljs-number">5</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-number">2</span> * <span class="hljs-number">3</span> + <span class="hljs-number">2</span>
<span class="hljs-number">8</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-number">3</span> * <span class="hljs-number">3</span> + <span class="hljs-number">2</span>
<span class="hljs-number">11</span></code></pre>

<p>If we wanted to do this with a larger set of numbers, that'd be a lot of repeated
code! Let's write a function to capture this operation given any input number.</p>

<pre><code class="hljs python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">foo</span><span class="hljs-params">(x)</span>:</span>
    <span class="hljs-keyword">return</span> x * <span class="hljs-number">3</span> + <span class="hljs-number">2</span></code></pre>

<p>This function, called <code>foo</code>, takes in a single <strong>argument</strong> and will <strong>return</strong> the
result of multiplying that argument by 3 and adding 2.</p>

<p>Now we can <strong>call</strong> this function whenever we want this operation to be done:</p>

<pre><code class="hljs python"><span class="hljs-meta">&gt;&gt;&gt; </span>foo(<span class="hljs-number">1</span>)
<span class="hljs-number">5</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>foo(<span class="hljs-number">2</span>)
<span class="hljs-number">8</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>foo(<span class="hljs-number">1000</span>)
<span class="hljs-number">3002</span></code></pre>

<p>Applying a function to some arguments is done with a <strong>call expression</strong>.</p>


<h3 id="call-expressions">Call expressions</h3>


<p>A call expression applies a function, which may or may not accept
arguments. The call expression evaluates to the function's return value.</p>

<p>The syntax of a function call:</p>

<pre><code class="hljs">  add   (    2   ,    3   )
   |         |        |
operator  operand  operand</code></pre>

<p>Every call expression requires a set of parentheses delimiting its
comma-separated operands.</p>

<p>To evaluate a function call:</p>

<ol>
  <li>Evaluate the operator, and then the operands (from left to right).</li>
  <li>Apply the operator to the operands (the values of the operands).</li>
</ol>

<p>If an operand is a nested call expression, then these two steps are
applied to that inner operand first in order to evaluate the outer operand.</p>


<h3 id="return-and-print"><code>return</code> and <code>print</code></h3>


<p>Most functions that you define will contain a <code>return</code> statement. The <code>return</code>
statement will give the result of some computation back to the caller of the
function and exit the function. For example, the function <code>square</code> below takes
in a number <code>x</code> and returns its square.</p>

<pre><code class="hljs python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">square</span><span class="hljs-params">(x)</span>:</span>
    <span class="hljs-string">"""
    &gt;&gt;&gt; square(4)
    16
    """</span>
    <span class="hljs-keyword">return</span> x * x</code></pre>

<p>When Python executes a <code>return</code> statement, the function terminates immediately.
If Python reaches the end of the function body without executing a <code>return</code>
statement, it will automatically return <code>None</code>.</p>

<p>In contrast, the <code>print</code> function is used to display values in the Terminal.
This can lead to some confusion between <code>print</code> and <code>return</code> because calling a
function in the Python interpreter will print out the function's return value.</p>

<p>However, unlike a <code>return</code> statement, when Python evaluates a <code>print</code>
expression, the function does <em>not</em> terminate immediately.</p>

<pre><code class="hljs python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">what_prints</span><span class="hljs-params">()</span>:</span>
    print(<span class="hljs-string">'Hello World!'</span>)
    <span class="hljs-keyword">return</span> <span class="hljs-string">'Exiting this function.'</span>
    print(<span class="hljs-string">'61A is awesome!'</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>what_prints()
Hello World!
<span class="hljs-string">'Exiting this function.'</span></code></pre>

<blockquote><p>Notice also that <code>print</code> will display text <strong>without the quotes</strong>, but
<code>return</code> will preserve the quotes.
</p></blockquote></div>
<br>

        <button id="toggle-5" class="btn btn-outline btn-lg alwaystoggle toggle" style="display: inline-block;">
        Control<noscript> (enable JavaScript)</noscript>
        </button>
        <div class="solution toggle-5"><p></p>

<h2 id="control">Control</h2>


<h3 id="boolean-operators">Boolean Operators</h3>


<p>Python supports three boolean operators: <code>and</code>, <code>or</code>, and <code>not</code>:</p>

<pre><code class="hljs python"><span class="hljs-meta">&gt;&gt;&gt; </span>a = <span class="hljs-number">4</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>a &lt; <span class="hljs-number">2</span> <span class="hljs-keyword">and</span> a &gt; <span class="hljs-number">0</span>
<span class="hljs-literal">False</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>a &lt; <span class="hljs-number">2</span> <span class="hljs-keyword">or</span> a &gt; <span class="hljs-number">0</span>
<span class="hljs-literal">True</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">not</span> (a &gt; <span class="hljs-number">0</span>)
<span class="hljs-literal">False</span></code></pre>

<ul>
  <li><code>and</code> evaluates to <code>True</code> only if both operands evaluate to <code>True</code>.
  If at least one operand is <code>False</code>, then <code>and</code> evaluates to <code>False</code>.</li>
  <li><code>or</code> evaluates to <code>True</code> if at least one operand evaluates to <code>True</code>.
  If both operands are <code>False</code>, then <code>or</code> evaluates to <code>False</code>.</li>
  <li><code>not</code> evaluates to <code>True</code> if its operand evaluates to <code>False</code>. It evaluates
  to <code>False</code> if its operand evalutes to <code>True</code>.</li>
</ul>

<p>What do you think the following expression evaluates to? Try it out in the
Python interpreter.</p>

<pre><code class="hljs python"><span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-literal">True</span> <span class="hljs-keyword">and</span> <span class="hljs-keyword">not</span> <span class="hljs-literal">False</span> <span class="hljs-keyword">or</span> <span class="hljs-keyword">not</span> <span class="hljs-literal">True</span> <span class="hljs-keyword">and</span> <span class="hljs-literal">False</span></code></pre>

<p>It is difficult to read complex expressions, like the one above, and understand
how a program will behave. Using parentheses can make your code easier to
understand. Python interprets that expression in the
following way:</p>

<pre><code class="hljs python"><span class="hljs-meta">&gt;&gt;&gt; </span>(<span class="hljs-literal">True</span> <span class="hljs-keyword">and</span> (<span class="hljs-keyword">not</span> <span class="hljs-literal">False</span>)) <span class="hljs-keyword">or</span> ((<span class="hljs-keyword">not</span> <span class="hljs-literal">True</span>) <span class="hljs-keyword">and</span> <span class="hljs-literal">False</span>)</code></pre>

<p>This is because boolean operators, like arithmetic operators, have an order of operation:</p>

<ul>
  <li><code>not</code> has the highest priority</li>
  <li><code>and</code></li>
  <li><code>or</code> has the lowest priority</li>
</ul>

<p><strong>Truthy and Falsey Values</strong>: It turns out <code>and</code> and <code>or</code> work on more than just booleans (<code>True</code>,
<code>False</code>). Python values such as <code>0</code>, <code>None</code>, <code>''</code> (the empty string), and <code>[]</code>
(the empty list) are considered false values. <em>All</em> other values are considered
true values.</p>


<h4 id="short-circuiting">Short Circuiting</h4>


<p>What do you think will happen if we type the following into Python?</p>

<pre><code class="hljs">1 / 0</code></pre>

<p>Try it out in Python! You should see a <code>ZeroDivisionError</code>. But what about this expression?</p>

<pre><code class="hljs python"><span class="hljs-literal">True</span> <span class="hljs-keyword">or</span> <span class="hljs-number">1</span> / <span class="hljs-number">0</span></code></pre>

<p>It evaluates to <code>True</code> because Python's <code>and</code> and <code>or</code> operators <em>short-circuit</em>. That is, they don't necessarily evaluate every operand.</p>

<div class="table-responsive">
  <table class="table table-bordered">
    <tbody><tr>
      <th>Operator</th>
      <th>Checks if:</th>
      <th>Evaluates from left to right up to:</th>
      <th>Example</th>
    </tr>
    <tr>
      <td>AND</td>
      <td>All values are true</td>
      <td>The first false value</td>
      <td><code>False and 1 / 0</code> evaluates to <code>False</code></td>
    </tr>
    <tr>
      <td>OR</td>
      <td>At least one value is true</td>
      <td>The first true value</td>
      <td><code>True or 1 / 0</code> evaluates to <code>True</code></td>
    </tr>
  </tbody></table>
</div>

<p>Short-circuiting happens when the operator reaches an operand that allows them to make a conclusion about the expression. For example, <code>and</code> will short-circuit as soon as it reaches the first false value because it then knows that not all the values are true.</p>

<p>If <code>and</code> and <code>or</code> do not <em>short-circuit</em>, they just return the last
value; another way to remember this is that <code>and</code> and <code>or</code> always return the last
thing they evaluate, whether they short circuit or not. Keep in mind that <code>and</code> and <code>or</code>
don't always return booleans when using values other than <code>True</code> and <code>False</code>.</p>


<h3 id="if-statements">If Statements</h3>


<p>You can review the syntax of <code>if</code> statements in
<a href="http://composingprograms.com/pages/15-control.html#conditional-statements">Section 1.5.4</a>
of Composing Programs.</p>

<blockquote><p><em>Tip</em>: We sometimes see code that looks like this:</p>

<pre><code class="hljs python"><span class="hljs-keyword">if</span> x &gt; <span class="hljs-number">3</span>:
    <span class="hljs-keyword">return</span> <span class="hljs-literal">True</span>
<span class="hljs-keyword">else</span>:
    <span class="hljs-keyword">return</span> <span class="hljs-literal">False</span></code></pre>

<p>This can be written more concisely as <code>return x &gt; 3</code>. If your code looks like
the code above, see if you can rewrite it more clearly!</p></blockquote>


<h3 id="while-loops">While Loops</h3>


<p>You can review the syntax of <code>while</code> loops in
<a href="http://composingprograms.com/pages/15-control.html#iteration">Section 1.5.5</a>
of Composing Programs.
</p></div>
<br>

        <button id="toggle-6" class="btn btn-outline btn-lg alwaystoggle toggle" style="display: inline-block;">
        Error Messages<noscript> (enable JavaScript)</noscript>
        </button>
        <div class="solution toggle-6"><p></p>

<h2 id="error-messages">Error Messages</h2>


<p>By now, you've probably seen a couple of error messages.
They might look intimidating, but error messages are very helpful
for debugging code. The following are some common types of errors:</p>

<div class="table-responsive">
  <table class="table table-bordered">
    <tbody><tr>
      <th>Error Types</th>
      <th>Descriptions</th>
    </tr>
    <tr>
      <td>SyntaxError</td>
      <td align="left">Contained improper syntax (e.g. missing a colon after an <code>if</code> statement or forgetting to close parentheses/quotes)</td>
    </tr>
    <tr>
      <td>IndentationError</td>
      <td align="left">Contained improper indentation (e.g. inconsistent indentation of a function body)</td>
    </tr>
    <tr>
      <td>TypeError</td>
      <td align="left">Attempted operation on incompatible types (e.g. trying to add a function and a number) or called function with the wrong number of arguments</td>
    </tr>
    <tr>
      <td>ZeroDivisionError</td>
      <td align="left">Attempted division by zero</td>
    </tr>
  </tbody></table>
</div>

<p>Using these descriptions of error messages, you should be able to get
a better idea of what went wrong with your code. <strong>If you run into
error messages, try to identify the problem before asking for
help.</strong> You can often Google unfamiliar error messages to see if others have
made similar mistakes to help you debug.</p>

<p>For example:</p>

<pre><code class="hljs python"><span class="hljs-meta">&gt;&gt;&gt; </span>square(<span class="hljs-number">3</span>, <span class="hljs-number">3</span>)
Traceback (most recent call last):
  File <span class="hljs-string">"&lt;stdin&gt;"</span>, line <span class="hljs-number">1</span>, <span class="hljs-keyword">in</span> &lt;module&gt;
TypeError: square() takes <span class="hljs-number">1</span> positional argument but <span class="hljs-number">2</span> were given</code></pre>

<p>Note:</p>

<ul>
  <li>The last line of an error message tells us the type of the error. In the
  example above, we have a <code>TypeError</code>.</li>
  <li>The error message tells us what we did wrong -- we gave <code>square</code> 2 arguments
  when it can only take in 1 argument. In general, the last line is the most
  helpful.</li>
  <li><p>The second to last line of the error message tells us on which line the
  error occurred. This helps us track down the error. In the example above,
  <code>TypeError</code> occurred at <code>line 1</code>.
  </p></li></ul></div><p></p>

  <h1 id="required-questions">Required Questions</h1>



<h2 id="what-would-python-display-part-1">What Would Python Display? (Part 1)</h2>


<h3 class="question" id="q1">Q1: WWPD: Control</h3>

<blockquote><p>Use Ok to test your knowledge with the following "What Would Python Display?"
questions:</p>

<pre><code class="hljs">python3 ok -q control -u</code></pre>

<p><strong>Hint</strong>: Make sure your <code>while</code> loop conditions eventually evaluate to a false value, or they'll never stop! Typing <code>Ctrl-C</code> will stop infinite loops in the interpreter.</p></blockquote>

<pre><code class="hljs python"><span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">xk</span><span class="hljs-params">(c, d)</span>:</span>
<span class="hljs-meta">... </span>    <span class="hljs-keyword">if</span> c == <span class="hljs-number">4</span>:
<span class="hljs-meta">... </span>        <span class="hljs-keyword">return</span> <span class="hljs-number">6</span>
<span class="hljs-meta">... </span>    <span class="hljs-keyword">elif</span> d &gt;= <span class="hljs-number">4</span>:
<span class="hljs-meta">... </span>        <span class="hljs-keyword">return</span> <span class="hljs-number">6</span> + <span class="hljs-number">7</span> + c
<span class="hljs-meta">... </span>    <span class="hljs-keyword">else</span>:
<span class="hljs-meta">... </span>        <span class="hljs-keyword">return</span> <span class="hljs-number">25</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>xk(<span class="hljs-number">10</span>, <span class="hljs-number">10</span>)
<div class="alt prompt-1">______</div><div class="solution prompt-1">23</div>
<span class="hljs-meta">&gt;&gt;&gt; </span>xk(<span class="hljs-number">10</span>, <span class="hljs-number">6</span>)
<div class="alt prompt-1">______</div><div class="solution prompt-1">23</div>
<span class="hljs-meta">&gt;&gt;&gt; </span>xk(<span class="hljs-number">4</span>, <span class="hljs-number">6</span>)
<div class="alt prompt-1">______</div><div class="solution prompt-1">6</div>
<span class="hljs-meta">&gt;&gt;&gt; </span>xk(<span class="hljs-number">0</span>, <span class="hljs-number">0</span>)
<div class="alt prompt-1">______</div><div class="solution prompt-1">25</div></code></pre>
        <button id="prompt-1" class="btn btn-outline btn-lg solutiontoggle prompt">
        Toggle Solution<noscript> (enable JavaScript)</noscript>
        </button>
        

<pre><code class="hljs python"><span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">how_big</span><span class="hljs-params">(x)</span>:</span>
<span class="hljs-meta">... </span>    <span class="hljs-keyword">if</span> x &gt; <span class="hljs-number">10</span>:
<span class="hljs-meta">... </span>        print(<span class="hljs-string">'huge'</span>)
<span class="hljs-meta">... </span>    <span class="hljs-keyword">elif</span> x &gt; <span class="hljs-number">5</span>:
<span class="hljs-meta">... </span>        <span class="hljs-keyword">return</span> <span class="hljs-string">'big'</span>
<span class="hljs-meta">... </span>    <span class="hljs-keyword">elif</span> x &gt; <span class="hljs-number">0</span>:
<span class="hljs-meta">... </span>        print(<span class="hljs-string">'small'</span>)
<span class="hljs-meta">... </span>    <span class="hljs-keyword">else</span>:
<span class="hljs-meta">... </span>        print(<span class="hljs-string">"nothin"</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>how_big(<span class="hljs-number">7</span>)
<div class="alt prompt-2">______</div><div class="solution prompt-2"><span class="hljs-string">'big'</span></div>
<span class="hljs-meta">&gt;&gt;&gt; </span>how_big(<span class="hljs-number">12</span>)
<div class="alt prompt-2">______</div><div class="solution prompt-2">huge</div>
<span class="hljs-meta">&gt;&gt;&gt; </span>how_big(<span class="hljs-number">1</span>)
<div class="alt prompt-2">______</div><div class="solution prompt-2">small</div>
<span class="hljs-meta">&gt;&gt;&gt; </span>how_big(<span class="hljs-number">-1</span>)
<div class="alt prompt-2">______</div><div class="solution prompt-2">nothin</div></code></pre>
        <button id="prompt-2" class="btn btn-outline btn-lg solutiontoggle prompt">
        Toggle Solution<noscript> (enable JavaScript)</noscript>
        </button>
        

<pre><code class="hljs python"><span class="hljs-meta">&gt;&gt;&gt; </span>n = <span class="hljs-number">3</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">while</span> n &gt;= <span class="hljs-number">0</span>:
<span class="hljs-meta">... </span>    n -= <span class="hljs-number">1</span>
<span class="hljs-meta">... </span>    print(n)
<div class="alt prompt-3">______</div><div class="solution prompt-3">2
<span class="hljs-number">1</span>
<span class="hljs-number">0</span>
<span class="hljs-number">-1</span></div></code></pre>
        <button id="prompt-3" class="btn btn-outline btn-lg solutiontoggle prompt">
        Toggle Solution<noscript> (enable JavaScript)</noscript>
        </button>
        

<pre><code class="hljs python"><span class="hljs-meta">&gt;&gt;&gt; </span>positive = <span class="hljs-number">28</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">while</span> positive:
<span class="hljs-meta">... </span>   print(<span class="hljs-string">"positive?"</span>)
<span class="hljs-meta">... </span>   positive -= <span class="hljs-number">3</span>
<div class="alt prompt-4">______</div><div class="solution prompt-4">Infinite Loop</div></code></pre>
        <button id="prompt-4" class="btn btn-outline btn-lg solutiontoggle prompt">
        Toggle Solution<noscript> (enable JavaScript)</noscript>
        </button>
        

<pre><code class="hljs python"><span class="hljs-meta">&gt;&gt;&gt; </span>positive = <span class="hljs-number">-9</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>negative = <span class="hljs-number">-12</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">while</span> negative:
<span class="hljs-meta">... </span>   <span class="hljs-keyword">if</span> positive:
<span class="hljs-meta">... </span>       print(negative)
<span class="hljs-meta">... </span>   positive += <span class="hljs-number">3</span>
<span class="hljs-meta">... </span>   negative += <span class="hljs-number">3</span>
<div class="alt prompt-5">______</div><div class="solution prompt-5"><span class="hljs-number">-12</span>
<span class="hljs-number">-9</span>
<span class="hljs-number">-6</span></div></code></pre>
        <button id="prompt-5" class="btn btn-outline btn-lg solutiontoggle prompt">
        Toggle Solution<noscript> (enable JavaScript)</noscript>
        </button>
        

<h3 class="question" id="q2">Q2: WWPD: Veritasiness</h3>

<blockquote><p>Use Ok to test your knowledge with the following "What Would Python Display?"
questions:</p>

<pre><code class="hljs">python3 ok -q short-circuit -u</code></pre></blockquote>

<pre><code class="hljs python"><span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-literal">True</span> <span class="hljs-keyword">and</span> <span class="hljs-number">13</span>
<div class="alt prompt-6">______</div><div class="solution prompt-6">13</div>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-literal">False</span> <span class="hljs-keyword">or</span> <span class="hljs-number">0</span>
<div class="alt prompt-6">______</div><div class="solution prompt-6">0</div>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">not</span> <span class="hljs-number">10</span>
<div class="alt prompt-6">______</div><div class="solution prompt-6">False</div>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">not</span> <span class="hljs-literal">None</span>
<div class="alt prompt-6">______</div><div class="solution prompt-6">True</div></code></pre>
        <button id="prompt-6" class="btn btn-outline btn-lg solutiontoggle prompt">
        Toggle Solution<noscript> (enable JavaScript)</noscript>
        </button>
        

<pre><code class="hljs python"><span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-literal">True</span> <span class="hljs-keyword">and</span> <span class="hljs-number">1</span> / <span class="hljs-number">0</span> <span class="hljs-keyword">and</span> <span class="hljs-literal">False</span>
<div class="alt prompt-7">______</div><div class="solution prompt-7">Error (ZeroDivisionError)</div>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-literal">True</span> <span class="hljs-keyword">or</span> <span class="hljs-number">1</span> / <span class="hljs-number">0</span> <span class="hljs-keyword">or</span> <span class="hljs-literal">False</span>
<div class="alt prompt-7">______</div><div class="solution prompt-7">True</div>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-literal">True</span> <span class="hljs-keyword">and</span> <span class="hljs-number">0</span>
<div class="alt prompt-7">______</div><div class="solution prompt-7">0</div>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-literal">False</span> <span class="hljs-keyword">or</span> <span class="hljs-number">1</span>
<div class="alt prompt-7">______</div><div class="solution prompt-7">1</div>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-number">1</span> <span class="hljs-keyword">and</span> <span class="hljs-number">3</span> <span class="hljs-keyword">and</span> <span class="hljs-number">6</span> <span class="hljs-keyword">and</span> <span class="hljs-number">10</span> <span class="hljs-keyword">and</span> <span class="hljs-number">15</span>
<div class="alt prompt-7">______</div><div class="solution prompt-7">15</div>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-number">-1</span> <span class="hljs-keyword">and</span> <span class="hljs-number">1</span> &gt; <span class="hljs-number">0</span>
<div class="alt prompt-7">______</div><div class="solution prompt-7">True</div>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-number">0</span> <span class="hljs-keyword">or</span> <span class="hljs-literal">False</span> <span class="hljs-keyword">or</span> <span class="hljs-number">2</span> <span class="hljs-keyword">or</span> <span class="hljs-number">1</span> / <span class="hljs-number">0</span>
<div class="alt prompt-7">______</div><div class="solution prompt-7">2</div></code></pre>
        <button id="prompt-7" class="btn btn-outline btn-lg solutiontoggle prompt">
        Toggle Solution<noscript> (enable JavaScript)</noscript>
        </button>
        

<pre><code class="hljs python"><span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">not</span> <span class="hljs-number">0</span>
<div class="alt prompt-8">______</div><div class="solution prompt-8">True</div>
<span class="hljs-meta">&gt;&gt;&gt; </span>(<span class="hljs-number">1</span> + <span class="hljs-number">1</span>) <span class="hljs-keyword">and</span> <span class="hljs-number">1</span>
<div class="alt prompt-8">______</div><div class="solution prompt-8">1</div>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-number">1</span>/<span class="hljs-number">0</span> <span class="hljs-keyword">or</span> <span class="hljs-literal">True</span>
<div class="alt prompt-8">______</div><div class="solution prompt-8">Error</div>
<span class="hljs-meta">&gt;&gt;&gt; </span>(<span class="hljs-literal">True</span> <span class="hljs-keyword">or</span> <span class="hljs-literal">False</span>) <span class="hljs-keyword">and</span> <span class="hljs-literal">False</span>
<div class="alt prompt-8">______</div><div class="solution prompt-8">False</div></code></pre>
        <button id="prompt-8" class="btn btn-outline btn-lg solutiontoggle prompt">
        Toggle Solution<noscript> (enable JavaScript)</noscript>
        </button>
        

<h3 class="question" id="q3">Q3: Debugging Quiz!</h3>

<p>The following is a quick quiz on different debugging techniques you should use
in this class. You should refer to <a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/articles/debugging.html">this document</a> to
answer the questions!</p>

<p>Run the following to run the quiz.</p>

<pre><code class="hljs">python3 ok -q debugging-quiz -u</code></pre>


<h2 id="coding-practice">Coding Practice</h2>


<h3 class="question" id="q4">Q4: Falling Factorial</h3>

<p>Let's write a function <code>falling</code>, which is a "falling" factorial
that takes two arguments, <code>n</code> and <code>k</code>, and returns the product of <code>k</code>
consecutive numbers, starting from <code>n</code> and working downwards.</p>

<solution>

<pre><code class="hljs python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">falling</span><span class="hljs-params">(n, k)</span>:</span>
    <span class="hljs-string">"""Compute the falling factorial of n to depth k.

    &gt;&gt;&gt; falling(6, 3)  # 6 * 5 * 4
    120
    &gt;&gt;&gt; falling(4, 3)  # 4 * 3 * 2
    24
    &gt;&gt;&gt; falling(4, 1)  # 4
    4
    &gt;&gt;&gt; falling(4, 0)
    1
    """</span>
    <span class="hljs-string">"*** YOUR CODE HERE ***"</span>
</code></pre>

</solution>

<p>Use Ok to test your code:</p><pre><code class="nohighlight">python3 ok -q falling</code></pre>

<h3 class="question" id="q5">Q5: Sum Digits</h3>

<p>Write a function that takes in a nonnegative integer and sums its digits. (Using
floor division and modulo might be helpful here!)</p>

<solution>

<pre><code class="hljs python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">sum_digits</span><span class="hljs-params">(y)</span>:</span>
    <span class="hljs-string">"""Sum all the digits of y.

    &gt;&gt;&gt; sum_digits(10) # 1 + 0 = 1
    1
    &gt;&gt;&gt; sum_digits(4224) # 4 + 2 + 2 + 4 = 12
    12
    &gt;&gt;&gt; sum_digits(1234567890)
    45
    &gt;&gt;&gt; a = sum_digits(123) # make sure that you are using return rather than print
    &gt;&gt;&gt; a
    6
    """</span>
    <span class="hljs-string">"*** YOUR CODE HERE ***"</span>
</code></pre>

</solution>

<p>Use Ok to test your code:</p><pre><code class="nohighlight">python3 ok -q sum_digits</code></pre>


<h2 id="submit">Submit</h2>


<p>Make sure to submit this assignment by running:</p>

<pre><code class="hljs sql">python3 ok <span class="hljs-comment">--submit</span></code></pre>

<p><strong>Reminder</strong>: Please fill out the Lab 0 survey (also included at the beginning of this assignment): <a href="https://forms.gle/BP3tcRgqPhHq4Ymf9">this survey</a></p>


<h1 id="extra-practice">Extra Practice</h1>


<blockquote><p>These questions are optional and will not affect your score on this assignment. However, they are
<strong>great practice</strong> for future assignments, projects, and exams. Attempting these questions is valuable in
helping cement your knowledge of course concepts, and it's fun!</p></blockquote>


<h2 id="what-would-python-display-part-2">What Would Python Display? (Part 2)</h2>


<h3 class="question" id="q6">Q6: WWPD: What If?</h3>

<blockquote><p>Use Ok to test your knowledge with the following "What Would Python Display?"
questions:</p>

<pre><code class="hljs">python3 ok -q if-statements -u</code></pre>

<p><strong>Hint</strong>: <code>print</code> (unlike <code>return</code>) does <em>not</em> cause the function to exit!</p></blockquote>

<!--
<pre><code>&gt;&gt;&gt; def so_big(x):
...     if x &gt; 10:
...         print(&#x27;huge&#x27;)
...     if x &gt; 5:
...         return &#x27;big&#x27;
...     if x &gt; 0:
...         print(&#x27;small&#x27;)
...     print(&quot;nothin&#x27;&quot;)
&gt;&gt;&gt; so_big(7)
<div class="alt prompt-9">______</div><div class="solution prompt-9">&#x27;&#x62;&#x69;&#x67;&#x27;</div>
&gt;&gt;&gt; so_big(12)
<div class="alt prompt-9">______</div><div class="solution prompt-9">&#x68;&#x75;&#x67;&#x65;&#xa;&#x27;&#x62;&#x69;&#x67;&#x27;</div>
&gt;&gt;&gt; so_big(1)
<div class="alt prompt-9">______</div><div class="solution prompt-9">&#x73;&#x6d;&#x61;&#x6c;&#x6c;&#xa;&#x6e;&#x6f;&#x74;&#x68;&#x69;&#x6e;&#x27;</div></code></pre>
        <button id='prompt-9' class='btn btn-outline btn-lg solutiontoggle prompt'>
        Toggle Solution<noscript> (enable JavaScript)</noscript>
        </button>
        
-->

<pre><code class="hljs python"><span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">ab</span><span class="hljs-params">(c, d)</span>:</span>
<span class="hljs-meta">... </span>    <span class="hljs-keyword">if</span> c &gt; <span class="hljs-number">5</span>:
<span class="hljs-meta">... </span>        print(c)
<span class="hljs-meta">... </span>    <span class="hljs-keyword">elif</span> c &gt; <span class="hljs-number">7</span>:
<span class="hljs-meta">... </span>        print(d)
<span class="hljs-meta">... </span>    print(<span class="hljs-string">'foo'</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>ab(<span class="hljs-number">10</span>, <span class="hljs-number">20</span>)
<div class="alt prompt-10">______</div><div class="solution prompt-10">10
foo</div></code></pre>
        <button id="prompt-10" class="btn btn-outline btn-lg solutiontoggle prompt">
        Toggle Solution<noscript> (enable JavaScript)</noscript>
        </button>
        

<pre><code class="hljs python"><span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">bake</span><span class="hljs-params">(cake, make)</span>:</span>
<span class="hljs-meta">... </span>    <span class="hljs-keyword">if</span> cake == <span class="hljs-number">0</span>:
<span class="hljs-meta">... </span>        cake = cake + <span class="hljs-number">1</span>
<span class="hljs-meta">... </span>        print(cake)
<span class="hljs-meta">... </span>    <span class="hljs-keyword">if</span> cake == <span class="hljs-number">1</span>:
<span class="hljs-meta">... </span>        print(make)
<span class="hljs-meta">... </span>    <span class="hljs-keyword">else</span>:
<span class="hljs-meta">... </span>        <span class="hljs-keyword">return</span> cake
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> make
<span class="hljs-meta">&gt;&gt;&gt; </span>bake(<span class="hljs-number">0</span>, <span class="hljs-number">29</span>)
<div class="alt prompt-11">______</div><div class="solution prompt-11">1
<span class="hljs-number">29</span>
<span class="hljs-number">29</span></div>
<span class="hljs-meta">&gt;&gt;&gt; </span>bake(<span class="hljs-number">1</span>, <span class="hljs-string">"mashed potatoes"</span>)
<div class="alt prompt-11">______</div><div class="solution prompt-11">mashed potatoes
<span class="hljs-string">'mashed potatoes'</span></div></code></pre>
        <button id="prompt-11" class="btn btn-outline btn-lg solutiontoggle prompt">
        Toggle Solution<noscript> (enable JavaScript)</noscript>
        </button>
        


<h2 id="more-coding-practice">More Coding Practice</h2>


<h3 class="question" id="q7">Q7: Double Eights</h3>

<p>Write a function that takes in a number and determines if the digits contain two
adjacent 8s.</p>

<solution>

<pre><code class="hljs python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">double_eights</span><span class="hljs-params">(n)</span>:</span>
    <span class="hljs-string">"""Return true if n has two eights in a row.
    &gt;&gt;&gt; double_eights(8)
    False
    &gt;&gt;&gt; double_eights(88)
    True
    &gt;&gt;&gt; double_eights(2882)
    True
    &gt;&gt;&gt; double_eights(880088)
    True
    &gt;&gt;&gt; double_eights(12345)
    False
    &gt;&gt;&gt; double_eights(80808080)
    False
    """</span>
    <span class="hljs-string">"*** YOUR CODE HERE ***"</span>
</code></pre>

</solution>

<p>Use Ok to test your code:</p><pre><code class="nohighlight">python3 ok -q double_eights</code></pre>
<script>
    $('.alwaystoggle').css('display', 'inline-block');
    $('.alwaystoggle').click(function() {
      var solution_id = $(this).attr('id');
      $('div.' + solution_id).slideToggle(600);
    });
</script>

  </div>

  <div class="col-md-3 sticky">
    <nav class="hidden-print hidden-sm hidden-xs sidebar">
      <ul class="nav nav-stacked noselect">
  <li class=""><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/lab/lab01/#quick-logistics-review">Quick Logistics Review</a></li>
  <ul class="nav nav-stacked noselect">
    <li><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/lab/lab01/#using-python">Using Python</a></li>
    <li><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/lab/lab01/#using-ok">Using OK</a></li>
  </ul>
  <li class=""><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/lab/lab01/#topics">Topics</a></li>
  <ul class="nav nav-stacked noselect">
    <li><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/lab/lab01/#division">Division</a></li>
    <li><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/lab/lab01/#functions">Functions</a></li>
    <ul class="nav nav-stacked noselect">
      <li><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/lab/lab01/#call-expressions">Call expressions</a></li>
      <li><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/lab/lab01/#return-and-print"><code>return</code> and <code>print</code></a></li>
    </ul>
    <li><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/lab/lab01/#control">Control</a></li>
    <ul class="nav nav-stacked noselect">
      <li><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/lab/lab01/#boolean-operators">Boolean Operators</a></li>
      <ul class="nav nav-stacked noselect">
        <li><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/lab/lab01/#short-circuiting">Short Circuiting</a></li>
      </ul>
      <li><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/lab/lab01/#if-statements">If Statements</a></li>
      <li><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/lab/lab01/#while-loops">While Loops</a></li>
    </ul>
    <li><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/lab/lab01/#error-messages">Error Messages</a></li>
  </ul>
  <li class=""><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/lab/lab01/#required-questions">Required Questions</a></li>
  <ul class="nav nav-stacked noselect">
    <li class=""><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/lab/lab01/#what-would-python-display-part-1">What Would Python Display? (Part 1)</a></li>
    <ul class="nav nav-stacked noselect">
      <li class=""><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/lab/lab01/#q1">Q1: WWPD: Control</a></li>
      <li class=""><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/lab/lab01/#q2">Q2: WWPD: Veritasiness</a></li>
      <li class=""><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/lab/lab01/#q3">Q3: Debugging Quiz!</a></li>
    </ul>
    <li class=""><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/lab/lab01/#coding-practice">Coding Practice</a></li>
    <ul class="nav nav-stacked noselect">
      <li class=""><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/lab/lab01/#q4">Q4: Falling Factorial</a></li>
      <li class=""><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/lab/lab01/#q5">Q5: Sum Digits</a></li>
    </ul>
    <li class=""><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/lab/lab01/#submit">Submit</a></li>
  </ul>
  <li class=""><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/lab/lab01/#extra-practice">Extra Practice</a></li>
  <ul class="nav nav-stacked noselect">
    <li class=""><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/lab/lab01/#what-would-python-display-part-2">What Would Python Display? (Part 2)</a></li>
    <ul class="nav nav-stacked noselect">
      <li class=""><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/lab/lab01/#q6">Q6: WWPD: What If?</a></li>
    </ul>
    <li class=""><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/lab/lab01/#more-coding-practice">More Coding Practice</a></li>
    <ul class="nav nav-stacked noselect">
      <li class=""><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/lab/lab01/#q7">Q7: Double Eights</a></li>
    </ul>
  </ul>
</ul>
    </nav>
  </div>
</div>

    </main>

    <footer class="container">
      <div class="row text-center">
        <div class="col col-sm-4">
          <h3><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/">CS 61A</a></h3>
          <ul class="nav nav-pills nav-stacked">
            <li><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/weekly.html">Weekly Schedule</a></li>
            <li><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/office-hours.html">Office Hours</a></li>
            <li><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/staff.html">Staff</a></li>
          </ul>
        </div>
        <div class="col col-sm-4">
          <h3><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/resources.html">Resources</a></h3>
          <ul class="nav nav-pills nav-stacked">
            <li><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/articles/studying.html">Studying Guide</a></li>
            <li><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/articles/debugging.html">Debugging Guide</a></li>
            <li><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/articles/composition.html">Composition Guide</a></li>
          </ul>
        </div>
        <div class="col col-sm-4">
          <h3><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/articles/about.html">Policies</a></h3>
          <ul class="nav nav-pills nav-stacked">
            <li><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/articles/about.html#assignments">Assignments</a></li>
            <li><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/articles/about.html#exams">Exams</a></li>
            <li><a href="https://inst.eecs.berkeley.edu/~cs61a/fa20/articles/about.html#grading">Grading</a></li>
          </ul>
        </div>
      </div>
    </footer>

    

<script src="./Lab 1_ Variables &amp; Functions, Control _ CS 61A Fall 2020_files/sketchy.js.下载"></script>
<script>
  $('.sidebar ul').addClass('nav nav-stacked noselect');
  $('body').scrollspy({
    target: '.sidebar',
    offset: 40
  });

  function goToId(id) {
    var target = $(id);
    target.parent().show();
    $('html,body').animate({
      scrollTop: target.offset().top,
    }, 100);
    $("body").scrollspy('refresh');
  }

  if (location.hash) {
    setTimeout(function() {
      if (location.hash) {
        goToId(location.hash);
      }
    }, 1);
  }

  $("a").click(function(event) {
    var urlBeforeHashRegEx = new RegExp("^"+window.location.href.split("#")[0]);
    if (/^#/.test(this.hash) && urlBeforeHashRegEx.test(this.href)) {
      event.preventDefault();
      goToId(this.hash);
      document.location.hash = this.hash;
    }
  });
</script>

  
<canvas width="1528" height="8347" style="cursor: crosshair; top: 0px; left: 0px; position: absolute; z-index: 99; background-color: rgba(0, 0, 0, 0.25); user-select: none; pointer-events: none; display: none; --darkreader-inline-bgcolor: rgba(0, 0, 0, 0.25);" data-darkreader-inline-bgcolor=""></canvas></body><div style="all: initial;"><div id="__hcfy__" style="all: initial;"><template shadowrootmode="open"><style class="darkreader darkreader--invert" media="screen">.jfk-bubble.gtx-bubble, .captcheck_answer_label > input + img, span#closed_text > img[src^="https://www.gstatic.com/images/branding/googlelogo"], span[data-href^="https://www.hcaptcha.com/"] > #icon, #bit-notification-bar-iframe, ::-webkit-calendar-picker-indicator {
    filter: invert(100%) hue-rotate(180deg) contrast(90%) !important;
}</style><style>#root{-webkit-text-size-adjust:100%;box-sizing:border-box;font-size:14px;font-weight:400;letter-spacing:0;line-height:1.28581;text-transform:none;color:#182026;font-family:-apple-system,"BlinkMacSystemFont","Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Open Sans","Helvetica Neue","Icons16",sans-serif}#root{touch-action:manipulation}#root>.bp5-portal{z-index:9999999999}</style><link rel="stylesheet" href="chrome-extension://oikmahiipjniocckomdccmplodldodja/normalize.css"><link rel="stylesheet" href="chrome-extension://oikmahiipjniocckomdccmplodldodja/blueprint.css"><link rel="stylesheet" href="chrome-extension://oikmahiipjniocckomdccmplodldodja/blueprint-select.css"><link rel="stylesheet" href="chrome-extension://oikmahiipjniocckomdccmplodldodja/cropper.css"><style>#translate-panel{background-color:#f6f7f9;display:flex;flex-direction:column;padding-bottom:8px}.bp5-dark #translate-panel{background-color:#252a31}#translate-panel .fixed{flex-shrink:0;margin-bottom:10px}#translate-panel .body{flex-grow:1;overflow:auto;overscroll-behavior:contain}#translate-panel .body::-webkit-scrollbar{width:8px;background-color:rgba(0,0,0,0);-webkit-border-radius:100px}#translate-panel .body::-webkit-scrollbar:hover{background-color:rgba(0,0,0,.09)}#translate-panel .body::-webkit-scrollbar-thumb:vertical{background:rgba(0,0,0,.5);-webkit-border-radius:100px}#translate-panel .body::-webkit-scrollbar-thumb:vertical:active{background:rgba(0,0,0,.61);-webkit-border-radius:100px}#translate-panel.size-small,#translate-panel.size-small h6.bp5-heading,#translate-panel.size-small .bp5-control.bp5-large,#translate-panel.size-small textarea.bp5-input.bp5-small{font-size:14px}#translate-panel.size-small .phonetic-item,#translate-panel.size-small .quick-settings a{font-size:12px}#translate-panel.size-middle,#translate-panel.size-middle h6.bp5-heading,#translate-panel.size-middle .bp5-control.bp5-large,#translate-panel.size-middle textarea.bp5-input{font-size:18px}#translate-panel.size-middle .phonetic-item,#translate-panel.size-middle .quick-settings a{font-size:14px}#translate-panel.size-large,#translate-panel.size-large h6.bp5-heading,#translate-panel.size-large .bp5-control.bp5-large,#translate-panel.size-large textarea.bp5-input.bp5-large{font-size:22px}#translate-panel.size-large .source,#translate-panel.size-large .phonetic-item,#translate-panel.size-large .quick-settings a{font-size:18px}#translate-panel .bp5-button.bp5-small,#translate-panel .bp5-small .bp5-button{min-height:20px;min-width:20px}#translate-panel .header{display:flex;align-items:center;padding:4px 6px 4px 10px;border-bottom:1px solid #d1d1d1}.bp5-dark #translate-panel .header{border-bottom-color:rgba(17,20,24,.4)}#translate-panel .header .drag-block{min-width:5px;flex-shrink:0;flex-grow:1;align-self:stretch}#translate-panel .header .left{flex-shrink:0;display:flex}#translate-panel .header .right{flex-shrink:0;display:flex;align-items:center}#translate-panel .header .right .bp5-icon-arrow-right{flex-shrink:0;margin:0 5px}#translate-panel .header .right>.bp5-button{flex-shrink:0;margin:0 1px}#translate-panel .header .right>.bp5-button:last-child{margin-right:0}#translate-panel .quick-settings{padding:4px 9px;margin:0 1px}#translate-panel .quick-settings>div{margin-bottom:5px}#translate-panel .quick-settings .bp5-control{margin-bottom:0}#translate-panel .query-text{position:relative;padding:10px 10px 2px 10px}#translate-panel .query-text textarea.bp5-input{min-height:44px;font-family:system-ui,-apple-system,"Segoe UI","Roboto","Ubuntu","Cantarell","Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";overscroll-behavior:contain}#translate-panel .query-text .translate-btn{position:absolute;opacity:.6}#translate-panel .query-text .translate-btn:hover{opacity:1}#translate-panel .body{padding:0 10px}#translate-panel .body .bp5-card:first-child{margin-top:1px}#translate-panel .body .bp5-card:last-child{margin-bottom:1px}#translate-panel .body .no-api{margin:20px 0}.result-block{margin:8px 0;padding:2px 5px}.result-block .bp5-button{visibility:hidden}.result-block .error .bp5-button,.result-block:hover .bp5-button{visibility:visible}.result-block .legend{display:flex;align-items:center;justify-content:space-between}.result-block .legend .legend-left{display:flex;align-items:center}.result-block .legend .api-ico,.result-block .legend .bp5-heading{flex-shrink:0;white-space:nowrap}.result-block .legend .api-ico{display:inline-block;width:14px;height:14px;background-size:contain;margin-right:3px}.result-block .legend .bp5-heading{margin-bottom:0;margin-right:10px}.result-block .legend .source{cursor:pointer;font-size:12px;display:inline-flex;align-items:center}.result-block .legend .source .source-text{overflow:hidden}.result-block .legend .source .bp5-icon{position:relative;top:-1px;margin-left:1px}.result-block .phonetic{display:flex;flex-wrap:wrap}.result-block .phonetic .phonetic-item{display:flex;align-items:center;font-size:12px}.result-block .phonetic .phonetic-item:not(:last-child){margin-right:12px}.result-block .common-result p{line-height:1.3;margin:2px 0;overflow-wrap:break-word}.result-block .common-result .dict a{text-decoration:underline}.result-block .error{font-size:12px;padding:5px 10px}.result-block .dict-pos{margin-right:5px}.external-translators{margin-bottom:3px;padding:0;display:flex;flex-wrap:wrap}.external-translators>div{margin:0 5px 5px 0}.quick-links a{margin:0 5px 5px 0}#popper-container{width:250px;max-width:100%;position:absolute;left:0;top:0;z-index:9999999998;touch-action:none;transition:opacity .2s;background-color:#f6f7f9}.bp5-dark #popper-container{background-color:#252a31}#popper-container.show{opacity:1;pointer-events:auto;user-select:auto}#popper-container,#popper-container[data-popper-reference-hidden=true]{opacity:0;pointer-events:none;user-select:none}#popper-container .drag-block{cursor:grab}#popper-container.pin{position:fixed}#popper-container.pin .arrow{display:none}#popper-container .arrow,#popper-container .arrow::before{position:absolute;width:8px;height:8px;z-index:-1}#popper-container .arrow::before{content:"";transform:rotate(45deg);background:#f6f7f9}.bp5-dark #popper-container .arrow::before{background-color:#252a31}#popper-container .arrow{display:none}#popper-container.show[data-popper-placement]:not([data-popper-reference-hidden=true]) .arrow{display:block}#popper-container[data-popper-placement^=top] .arrow{bottom:-5px}#popper-container[data-popper-placement^=top] .arrow::before{border-right:1px solid #d1d1d1;border-bottom:1px solid #d1d1d1}#popper-container[data-popper-placement^=bottom] .arrow{top:-5px}#popper-container[data-popper-placement^=bottom] .arrow::before{border-left:1px solid #d1d1d1;border-top:1px solid #d1d1d1}#popper-container[data-popper-placement^=left] .arrow{right:-5px}#popper-container[data-popper-placement^=left] .arrow::before{border-right:1px solid #d1d1d1;border-top:1px solid #d1d1d1}#popper-container[data-popper-placement^=right] .arrow{left:-5px}#popper-container[data-popper-placement^=right] .arrow::before{border-left:1px solid #d1d1d1;border-bottom:1px solid #d1d1d1}#translate-btn{display:none;position:absolute;z-index:9999999999;left:0;top:0}#translate-btn .bp5-button{padding:2px;min-width:0;min-height:0}#translate-btn .btn-icon{width:18px;height:18px;background-image:url(chrome-extension://oikmahiipjniocckomdccmplodldodja/logo.png);background-size:contain}.bp5-dark #translate-btn .btn-icon{background-image:url(chrome-extension://oikmahiipjniocckomdccmplodldodja/logowhite36.png)}#translate-btn.show{display:block}.translate-type-selector .bp5-label{display:inline}.translate-type-selector .bp5-radio{margin-bottom:0}#ocr-container{position:fixed;z-index:99999999999999;left:0;top:0;right:0;bottom:0}#ocr-container .toolbar{display:none;position:absolute;z-index:1}#ocr-container img{max-width:100%}#app{cursor:default}.switch-pin{flex-shrink:0;cursor:pointer}.switch-pin .bp5-icon-pin{transition:transform .2s,color .2s;transform:rotate(-45deg)}.pin .switch-pin .bp5-icon-pin{transform:rotate(-70deg)}.cut-btn{margin-left:2px}.app-toaster-container{position:fixed !important;z-index:9999999999 !important}.app-toaster-container .bp5-toast{min-width:auto}#web-trs-panel .app-toaster-container{padding-right:0;padding-left:0}#web-trs-panel .page-trs-form-group{margin:0 0 0 0;align-items:center}#web-trs-panel .page-trs-form-group>label{width:70px}</style><div id="root" dir="ltr" class="bp5-dark"><div id="app" class="bp5-dark"><div id="translate-btn" style=""><button type="button" class="bp5-button"><span class="btn-icon"></span></button></div><div id="popper-container" class="bp5-elevation-4" style="width: 290px; transform: translate(0px, 0px);"><div id="translate-panel" class="size-small"><div class="fixed"><div class="header"><div class="left"><div class="switch-pin"><button type="button" class="bp5-button bp5-minimal bp5-small"><span aria-hidden="true" class="bp5-icon bp5-icon-pin"><svg data-icon="pin" height="14" role="img" viewBox="0 0 16 16" width="14"><path d="M9.41.92c-.51.51-.41 1.5.15 2.56L4.34 7.54C2.8 6.48 1.45 6.05.92 6.58l3.54 3.54-3.54 4.95 4.95-3.54 3.54 3.54c.53-.53.1-1.88-.96-3.42l4.06-5.22c1.06.56 2.04.66 2.55.15L9.41.92z" fill-rule="evenodd"></path></svg></span></button></div><button type="button" title="图片翻译" class="bp5-button bp5-minimal bp5-small"><span aria-hidden="true" class="bp5-icon bp5-icon-media"><svg data-icon="media" height="14" role="img" viewBox="0 0 16 16" width="14"><path d="M11.99 6.99c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zm3-5h-14c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h14c.55 0 1-.45 1-1v-10c0-.55-.45-1-1-1zm-1 9l-5-3-1 2-3-4-3 5v-7h12v7z" fill-rule="evenodd"></path></svg></span></button><button type="button" title="语音翻译" class="bp5-button bp5-minimal bp5-small"><span class="bp5-icon"><svg version="1.1" id="Capa_1" width="14" height="14" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 490.9 490.9" xml:space="preserve"><g><g><path d="M245.5,322.9c53,0,96.2-43.2,96.2-96.2V96.2c0-53-43.2-96.2-96.2-96.2s-96.2,43.2-96.2,96.2v130.5 C149.3,279.8,192.5,322.9,245.5,322.9z M173.8,96.2c0-39.5,32.2-71.7,71.7-71.7s71.7,32.2,71.7,71.7v130.5 c0,39.5-32.2,71.7-71.7,71.7s-71.7-32.2-71.7-71.7V96.2z"></path><path d="M94.4,214.5c-6.8,0-12.3,5.5-12.3,12.3c0,85.9,66.7,156.6,151.1,162.8v76.7h-63.9c-6.8,0-12.3,5.5-12.3,12.3 s5.5,12.3,12.3,12.3h152.3c6.8,0,12.3-5.5,12.3-12.3s-5.5-12.3-12.3-12.3h-63.9v-76.7c84.4-6.3,151.1-76.9,151.1-162.8 c0-6.8-5.5-12.3-12.3-12.3s-12.3,5.5-12.3,12.3c0,76.6-62.3,138.9-138.9,138.9s-138.9-62.3-138.9-138.9 C106.6,220,101.2,214.5,94.4,214.5z"></path></g></g></svg></span></button></div><div class="drag-block" title="按住不放可以拖动"></div><div class="right"><div style="font-size: 0px; position: relative;"><button type="button" title="你有 2 条未读消息" class="bp5-button bp5-minimal bp5-small"><span aria-hidden="true" class="bp5-icon bp5-icon-notifications"><svg data-icon="notifications" height="14" role="img" viewBox="0 0 16 16" width="14"><path d="M8 16c1.1 0 2-.9 2-2H6c0 1.1.9 2 2 2zm6-5c-.55 0-1-.45-1-1V6c0-2.43-1.73-4.45-4.02-4.9 0-.04.02-.06.02-.1 0-.55-.45-1-1-1S7 .45 7 1c0 .04.02.06.02.1A4.992 4.992 0 003 6v4c0 .55-.45 1-1 1s-1 .45-1 1 .45 1 1 1h12c.55 0 1-.45 1-1s-.45-1-1-1z" fill-rule="evenodd"></path></svg></span></button><div style="position: absolute; background: rgb(243, 1, 1); width: 6px; height: 6px; border-radius: 3px; right: 3px; top: 1px;"></div></div><button type="button" disabled="" title="添加到收藏夹" class="bp5-button bp5-disabled bp5-minimal bp5-small" tabindex="-1"><span aria-hidden="true" class="bp5-icon bp5-icon-star-empty"><svg data-icon="star-empty" height="14" role="img" viewBox="0 0 16 16" width="14"><path d="M16 6.11l-5.53-.84L8 0 5.53 5.27 0 6.11l4 4.1L3.06 16 8 13.27 12.94 16 12 10.21l4-4.1zM4.91 13.2l.59-3.62L3 7.02l3.45-.53L8 3.2l1.55 3.29 3.45.53-2.5 2.56.59 3.62L8 11.49 4.91 13.2z" fill-rule="evenodd"></path></svg></span></button><button type="button" class="bp5-button bp5-minimal bp5-small settings" title="快捷设置"><span aria-hidden="true" class="bp5-icon bp5-icon-cog"><svg data-icon="cog" height="14" role="img" viewBox="0 0 16 16" width="14"><path d="M15.19 6.39h-1.85c-.11-.37-.27-.71-.45-1.04l1.36-1.36c.31-.31.31-.82 0-1.13l-1.13-1.13a.803.803 0 00-1.13 0l-1.36 1.36c-.33-.17-.67-.33-1.04-.44V.79c0-.44-.36-.8-.8-.8h-1.6c-.44 0-.8.36-.8.8v1.86c-.39.12-.75.28-1.1.47l-1.3-1.3c-.3-.3-.79-.3-1.09 0L1.82 2.91c-.3.3-.3.79 0 1.09l1.3 1.3c-.2.34-.36.7-.48 1.09H.79c-.44 0-.8.36-.8.8v1.6c0 .44.36.8.8.8h1.85c.11.37.27.71.45 1.04l-1.36 1.36c-.31.31-.31.82 0 1.13l1.13 1.13c.31.31.82.31 1.13 0l1.36-1.36c.33.18.67.33 1.04.44v1.86c0 .44.36.8.8.8h1.6c.44 0 .8-.36.8-.8v-1.86c.39-.12.75-.28 1.1-.47l1.3 1.3c.3.3.79.3 1.09 0l1.09-1.09c.3-.3.3-.79 0-1.09l-1.3-1.3c.19-.35.36-.71.48-1.1h1.85c.44 0 .8-.36.8-.8v-1.6a.816.816 0 00-.81-.79zm-7.2 4.6c-1.66 0-3-1.34-3-3s1.34-3 3-3 3 1.34 3 3-1.34 3-3 3z" fill-rule="evenodd"></path></svg></span></button><button type="button" title="关闭(Esc)" class="bp5-button bp5-minimal bp5-small"><span aria-hidden="true" class="bp5-icon bp5-icon-cross"><svg data-icon="cross" height="18" role="img" viewBox="0 0 16 16" width="18"><path d="M9.41 8l3.29-3.29c.19-.18.3-.43.3-.71a1.003 1.003 0 00-1.71-.71L8 6.59l-3.29-3.3a1.003 1.003 0 00-1.42 1.42L6.59 8 3.3 11.29c-.19.18-.3.43-.3.71a1.003 1.003 0 001.71.71L8 9.41l3.29 3.29c.18.19.43.3.71.3a1.003 1.003 0 00.71-1.71L9.41 8z" fill-rule="evenodd"></path></svg></span></button></div></div><div class="bp5-collapse"><div class="bp5-collapse-body" aria-hidden="true"><div class="quick-settings bp5-card bp5-elevation-0"><div><span aria-controls="listbox-0" aria-haspopup="listbox" class="lang-select bp5-popover-target" aria-expanded="false" role="combobox"><button type="button" class="bp5-button bp5-small"><span class="bp5-button-text">自动检测</span><span aria-hidden="true" class="bp5-icon bp5-icon-caret-down"><svg data-icon="caret-down" height="16" role="img" viewBox="0 0 16 16" width="16"><path d="M12 6.5c0-.28-.22-.5-.5-.5h-7a.495.495 0 00-.37.83l3.5 4c.09.1.22.17.37.17s.28-.07.37-.17l3.5-4c.08-.09.13-.2.13-.33z" fill-rule="evenodd"></path></svg></span></button></span><span aria-hidden="true" class="bp5-icon bp5-icon-arrow-right" style="margin: 0px 10px;"><svg data-icon="arrow-right" height="12" role="img" viewBox="0 0 16 16" width="12"><path d="M14.7 7.29l-5-5a.965.965 0 00-.71-.3 1.003 1.003 0 00-.71 1.71l3.29 3.29H1.99c-.55 0-1 .45-1 1s.45 1 1 1h9.59l-3.29 3.29a1.003 1.003 0 001.42 1.42l5-5c.18-.18.29-.43.29-.71s-.12-.52-.3-.7z" fill-rule="evenodd"></path></svg></span><span aria-controls="listbox-1" aria-haspopup="listbox" class="lang-select bp5-popover-target" aria-expanded="false" role="combobox"><button type="button" class="bp5-button bp5-small"><span class="bp5-button-text">中文(简体)</span><span aria-hidden="true" class="bp5-icon bp5-icon-caret-down"><svg data-icon="caret-down" height="16" role="img" viewBox="0 0 16 16" width="16"><path d="M12 6.5c0-.28-.22-.5-.5-.5h-7a.495.495 0 00-.37.83l3.5 4c.09.1.22.17.37.17s.28-.07.37-.17l3.5-4c.08-.09.13-.2.13-.33z" fill-rule="evenodd"></path></svg></span></button></span></div><div><label class="bp5-control bp5-checkbox bp5-inline"><input type="checkbox"><span class="bp5-control-indicator"></span>谷歌</label><label class="bp5-control bp5-checkbox bp5-inline"><input type="checkbox"><span class="bp5-control-indicator"></span>DeepL</label><label class="bp5-control bp5-checkbox bp5-inline"><input type="checkbox"><span class="bp5-control-indicator"></span>ChatGPT</label><label class="bp5-control bp5-checkbox bp5-inline"><input type="checkbox"><span class="bp5-control-indicator"></span>Yandex</label><label class="bp5-control bp5-checkbox bp5-inline"><input type="checkbox"><span class="bp5-control-indicator"></span>百度</label><label class="bp5-control bp5-checkbox bp5-inline"><input type="checkbox" checked=""><span class="bp5-control-indicator"></span>百度(专业版)</label><label class="bp5-control bp5-checkbox bp5-inline"><input type="checkbox"><span class="bp5-control-indicator"></span>腾讯</label><label class="bp5-control bp5-checkbox bp5-inline"><input type="checkbox"><span class="bp5-control-indicator"></span>彩云</label><label class="bp5-control bp5-checkbox bp5-inline"><input type="checkbox"><span class="bp5-control-indicator"></span>阿里</label><label class="bp5-control bp5-checkbox bp5-inline"><input type="checkbox"><span class="bp5-control-indicator"></span>阿里(专业版)</label><label class="bp5-control bp5-checkbox bp5-inline"><input type="checkbox"><span class="bp5-control-indicator"></span>有道</label><label class="bp5-control bp5-checkbox bp5-inline"><input type="checkbox"><span class="bp5-control-indicator"></span>火山</label><label class="bp5-control bp5-checkbox bp5-inline"><input type="checkbox" checked=""><span class="bp5-control-indicator"></span>必应词典</label><label class="bp5-control bp5-checkbox bp5-inline"><input type="checkbox"><span class="bp5-control-indicator"></span>搜狗</label></div><div><label class="bp5-control bp5-checkbox bp5-inline"><input type="checkbox"><span class="bp5-control-indicator"></span>自动朗读</label><span aria-haspopup="true" class="bp5-popover-target"><label class="bp5-control bp5-checkbox bp5-disabled bp5-inline"><input disabled="" tabindex="0" type="checkbox"><span class="bp5-control-indicator"></span>自动复制</label></span></div><div><label class="bp5-control bp5-radio bp5-inline"><input name="Blueprint5.RadioGroup-0" type="radio" value="small" checked=""><span class="bp5-control-indicator"></span>小</label><label class="bp5-control bp5-radio bp5-inline"><input name="Blueprint5.RadioGroup-0" type="radio" value="middle"><span class="bp5-control-indicator"></span>中</label><label class="bp5-control bp5-radio bp5-inline"><input name="Blueprint5.RadioGroup-0" type="radio" value="large"><span class="bp5-control-indicator"></span>大</label></div><div><label class="bp5-control bp5-checkbox bp5-inline"><input type="checkbox"><span class="bp5-control-indicator"></span>显示文本框</label><label class="bp5-control bp5-checkbox bp5-inline" style="margin-right: 0px;"><input type="checkbox"><span class="bp5-control-indicator"></span>鼠标悬浮取词</label></div><a class="bp5-text-small">打开完整设置</a><a class="bp5-text-small" style="margin-left: 15px;"><span aria-hidden="true" class="bp5-icon bp5-icon-crown" style="position: relative; top: -1px;"><svg data-icon="crown" height="14" role="img" viewBox="0 0 16 16" width="14"><path d="M2 6l3 2 3-4 3 4 3-2-1 6H3L2 6zm6-5a1 1 0 110 2 1 1 0 010-2zM1 3a1 1 0 110 2 1 1 0 010-2zm14 0a1 1 0 110 2 1 1 0 010-2zM3 13h10v2H3v-2z" fill-rule="evenodd"></path></svg></span> 开通会员</a></div></div></div></div><div class="body"><p>请输入需要翻译的文本。</p></div></div><div class="arrow"></div></div><div id="web-trs-panel"></div></div></div></template></div></div></html>